<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="Promise.js"></script>
</head>
<body>
    <script>
        // Promise是一个构造函数
        //  构造函数有两个属性。PromiseState   PromiseResult
        let p = new Promise((resolve,reject)=>{
            // 执行器函数同步立刻执行
            // console.log('executor');
            // 并且执行器函数有两个参数 resolve，reject
            // resolve('ok');
            // 1. state: pending -> fulfilled
            // 2. result： undefined -> ok

            // reject('error');
            // 1. state: pending -> rejected
            // 2. result: undefined -> error

            // throw
            // throw 222;

            // 状态只能改变一次
            resolve('ok');
            reject('error');
        })
        console.log(p);
    </script>
</body>
</html>